package com.qf.fmall2203.prosku.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qf.fmall2203.introducepro.entity.Product;
import com.qf.fmall2203.introducepro.entity.ProductImg;
import com.qf.fmall2203.introducepro.service.IProductImgService;
import com.qf.fmall2203.introducepro.service.IProductService;
import com.qf.fmall2203.prosku.entity.ProductSku;
import com.qf.fmall2203.prosku.mapper.ProductSkuMapper;
import com.qf.fmall2203.prosku.service.IProductSkuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
 * <p>
 * 商品规格 每一件商品都有不同的规格，不同的规格又有不同的价格和优惠力度，规格表为此设计 服务实现类
 * </p>
 *
 * @author CM
 * @since 2023-02-14
 */
@Service
public class ProductSkuServiceImpl extends ServiceImpl<ProductSkuMapper, ProductSku> implements IProductSkuService {

    @Autowired
    IProductService productService;

    @Autowired
    IProductImgService productImgService;

    @Override
    public HashMap<String, Object> getProSku(Integer id) {

        HashMap<String, Object> map = new HashMap<>();
        HashMap<String, Object> map1 = new HashMap<>();

        Product product = productService.getOne(new QueryWrapper<Product>().eq("product_id", 3));

        List<ProductImg> productImgs = productImgService.list(new QueryWrapper<ProductImg>().eq("item_id", 3));

        List<ProductSku> productSkus = list(new QueryWrapper<ProductSku>().eq("product_id", 3));

        map1.put("product",product);

        map1.put("productSkus",productSkus);

        map1.put("productImgs",productImgs);

        map.put("code",10000);
        map.put("msg","success");
        map.put("data",map1);



        return map;
    }
}
